<template>
    <view class="page-branch-member">
        <view class="p-4" v-if="list.length == 0">
            <u-empty text="暂无数据" mode="list"></u-empty>
        </view> 
        <view class="fly-card">
            <view class="item"  v-for="(item,index) in list" :key="index">
                <view class="thumb">
                    <u-image :src="proxy.$util.getFullImage(item.appUserListVo.avatar)" width="80rpx" height="80rpx" shape="circle"></u-image>
                </view>
                <view class="content">
                    <view class="title font-bold">{{ item.appUserListVo.nickname || item.appUserListVo.username }}</view>
                    <view class="desc mt-2">
                        <fly-info label="角色" :value="getRoleName(item.roleId)"></fly-info>
                        <fly-info label="到期" :value="item.appUserListVo.membersDate"></fly-info>
                        <fly-info label="状态">
                            <text :class="'status-' + item.status">{{ getStatusName(item.status) }}</text>
                        </fly-info>
                        <!-- <fly-info label="信用积分"></fly-info> -->
                        <!-- <fly-info label="发布活动数量"></fly-info> -->
                    </view>
                    <view class="float-right" v-if="item.roleId == 3"><u-button class="btn-red" size="mini" @click="showAction(item)">处理</u-button></view>
                </view>
            </view>
        </view>
        <u-action-sheet :list="actionSheet.list" v-model="actionSheet.isShow" @click="selectActionSheet"></u-action-sheet>
    </view>
</template>
<script setup lang="ts">
const {proxy} = getCurrentInstance() as ComponentInternalInstance;
import FlyInfo from '@/components/FlyInfo/index';
import {onShow, onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
let pageParams = reactive();
let list = ref([]);
let actionSheet = reactive({
    isShow: false,
    row: {},
    list: [
        {id: '0', text: '正常'},
        {id: '1', text: '拉黑'},
        {id: '2', text: '冻结'},
    ],
});
const getList = () => {
    proxy.$http('get', '/admin/userGuilds/getGuildsMemberInfo/'+ pageParams.guildId, {}, (data,msg) => {
        // proxy.$http('get', '/admin/userGuilds/'+ pageParams.guildId, {}, (data,msg) => {
        list.value = data;
    })
};
const getRoleName = (val) => {
    let name = '普通会员';
    switch(val){
        case 1: 
            name = '会长';
            break;
        case 2: 
            name = '分会长';
            break;
        case 3:
            name = '普通会员';
            break;
    }
    return name;
}
const getStatusName = (val) => {
    let name = '正常';
    switch(val){
        case '0': 
            name = '正常';
            break;
        case '1': 
            name = '已拉黑';
            break;
        case '2':
            name = '已冻结';
            break;
    }
    return name;
}
const showAction = (row) => {
    actionSheet.info = row;
    actionSheet.isShow = true;
}
const selectActionSheet = (index) => {
    let obj = actionSheet.list[index];
    let params = {
        userId: actionSheet.info.userId,
        status: obj.id,
    }
    proxy.$http('get', '/admin/userGuilds/blacklist/'+actionSheet.info.guildId, params, (data,msg) => {
        uni.$u.toast('提交成功');
        getList();
    })
}
onPullDownRefresh(() => {
	getList();
	setTimeout( () => {
		uni.stopPullDownRefresh();
	}, 1000);
});
onReachBottom(() =>{
	getList();
});
onLoad(e => {
    pageParams = e;
})
onShow(() => {    
	getList('refresh');
})
</script>